package sort;

public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {1,4,3,2,7};
        sort(arr);
        for (int a:arr) {
            System.out.print(a);
        }
    }
    public static void sort(int[] arr) {
        for (int i = arr.length - 1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (arr[j] > arr[j + 1]) {
                    swap(arr, j, j + 1);
                }
            }
        }
    }

    public static void swap(int[] arr, int left, int right) {
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }
}
